﻿
package system.data;

import java.util.*;

import framework.core.*;
/*
	Author    :Jackey
	CreateTime:2008-03-03 10:05:52
*/
public class TableSequenceBase extends Table 
{
public static final String TABLE_NAME = "T_TABLE_SEQUENCE";

private static final String BACKUP_TABLE_NAME = "T_TABLE_SEQUENCE_BACKUP";

private static final String BACKUP_SEQ_NAME = "S_TABLE_SEQUENCE_BACKUP";


public static final String ID = "ID";

public static final String WAREHOUSE_CODE = "WAREHOUSE_CODE";

public static final String DATATABLE_NAME = "DATATABLE_NAME";

public static final String CUR_VAL = "CUR_VAL";

public static final String CREATE_TIME = "CREATE_TIME";

public static final String LAST_UPDATE_TIME = "LAST_UPDATE_TIME";


public static Vector m_fields = null;


private String m_id = ""; //ID

private String m_warehouse_code = ""; //仓库编码

private String m_datatable_name = ""; //数据表名

private int m_cur_val = Value.NULL_INT;  //当前值

private String m_create_time = ""; //创建时间

private String m_last_update_time = ""; //最后修改时间



	public String getId()
	{
	    return m_id;
	}
	public void  setId(String v)
	{
		if(getId().equals(v)) return ;
		m_id = v ;
		markDirty(ID);
	}



	

	public String getWarehouseCode()
	{
	    return m_warehouse_code;
	}
	public void  setWarehouseCode(String v)
	{
		if(getWarehouseCode().equals(v)) return ;
		m_warehouse_code = v ;
		markDirty(WAREHOUSE_CODE);
	}



	

	public String getDatatableName()
	{
	    return m_datatable_name;
	}
	public void  setDatatableName(String v)
	{
		if(getDatatableName().equals(v)) return ;
		m_datatable_name = v ;
		markDirty(DATATABLE_NAME);
	}



	

	public int getCurVal()
	{
	    return m_cur_val;
	}
	public void  setCurVal(int v)
	{
		if(getCurVal()==v) return ;
		m_cur_val = v ;
		markDirty(CUR_VAL);
	}



	

	public String getCreateTime()
	{
	    return m_create_time;
	}
	public void  setCreateTime(String v)
	{
		if(getCreateTime().equals(v)) return ;
		m_create_time = v ;
		markDirty(CREATE_TIME);
	}



	

	public String getLastUpdateTime()
	{
	    return m_last_update_time;
	}
	public void  setLastUpdateTime(String v)
	{
		if(getLastUpdateTime().equals(v)) return ;
		m_last_update_time = v ;
		markDirty(LAST_UPDATE_TIME);
	}



	



	public String viewId(DBConnection con) throws Exception
	{
		return Value.view(getId());
	}

	public String viewWarehouseCode(DBConnection con) throws Exception
	{
		return Value.view(getWarehouseCode());
	}

	public String viewDatatableName(DBConnection con) throws Exception
	{
		return Value.view(getDatatableName());
	}

	public String viewCurVal(DBConnection con) throws Exception
	{
		return Value.view(getCurVal());
	}

	public String viewCreateTime(DBConnection con) throws Exception
	{
		return Value.view(getCreateTime());
	}

	public String viewLastUpdateTime(DBConnection con) throws Exception
	{
		return Value.view(getLastUpdateTime());
	}



protected TableSequenceBase()
{
}

public void fill(TableSequencePageData pageData) throws Exception
{

	if(pageData.getId()!=null)
	{	
		setId(pageData.getId());
	}

	if(pageData.getWarehouseCode()!=null)
	{	
		setWarehouseCode(pageData.getWarehouseCode());
	}

	if(pageData.getDatatableName()!=null)
	{	
		setDatatableName(pageData.getDatatableName());
	}

	if( pageData.getCurVal()!=null && 
	   !pageData.getCurVal().equals(""))
	{	
		setCurVal(Integer.parseInt(pageData.getCurVal()));
	}

	if(pageData.getCreateTime()!=null)
	{	
		setCreateTime(pageData.getCreateTime());
	}

	if(pageData.getLastUpdateTime()!=null)
	{	
		setLastUpdateTime(pageData.getLastUpdateTime());
	}

}

public String getTableName() 
{
	return TABLE_NAME;
}

public String getBackupTableName() 
{
	return BACKUP_TABLE_NAME;
}

public String getBackupSeqName() 
{
	return BACKUP_SEQ_NAME;
}

public java.util.Vector getFields() 
{
	if(m_fields==null)
	{
		m_fields = new Vector();

		m_fields.add(new Field(ID,Value.TYPE_STRING,true,true,32,"ID"));

		m_fields.add(new Field(WAREHOUSE_CODE,Value.TYPE_STRING,false,true,50,"仓库编码"));

		m_fields.add(new Field(DATATABLE_NAME,Value.TYPE_STRING,false,true,50,"数据表名"));

		m_fields.add(new Field(CUR_VAL,Value.TYPE_INT,false,true,0,"当前值"));

		m_fields.add(new Field(CREATE_TIME,Value.TYPE_STRING,false,true,20,"创建时间"));

		m_fields.add(new Field(LAST_UPDATE_TIME,Value.TYPE_STRING,false,true,20,"最后修改时间"));
		
	}
	return m_fields;
}

public void initObject(java.sql.ResultSet rs) throws Exception
{

	m_id = getString(rs,ID);

	m_warehouse_code = getString(rs,WAREHOUSE_CODE);

	m_datatable_name = getString(rs,DATATABLE_NAME);

	m_cur_val = getInt(rs,CUR_VAL);

	m_create_time = getString(rs,CREATE_TIME);

	m_last_update_time = getString(rs,LAST_UPDATE_TIME);

	ms_new_flag = ConstDefine.NO;
}

public Value get(String f)
{

	if(f.equalsIgnoreCase(ID))
	{
		return new Value(getId());
	}

	if(f.equalsIgnoreCase(WAREHOUSE_CODE))
	{
		return new Value(getWarehouseCode());
	}

	if(f.equalsIgnoreCase(DATATABLE_NAME))
	{
		return new Value(getDatatableName());
	}

	if(f.equalsIgnoreCase(CUR_VAL))
	{
		return new Value(getCurVal());
	}

	if(f.equalsIgnoreCase(CREATE_TIME))
	{
		return new Value(getCreateTime());
	}

	if(f.equalsIgnoreCase(LAST_UPDATE_TIME))
	{
		return new Value(getLastUpdateTime());
	}
	
	return null;
}
public void set(String f,Value v) throws Exception
{

	if(f.equalsIgnoreCase(ID))
	{
		setId(v.getString());
	}

	if(f.equalsIgnoreCase(WAREHOUSE_CODE))
	{
		setWarehouseCode(v.getString());
	}

	if(f.equalsIgnoreCase(DATATABLE_NAME))
	{
		setDatatableName(v.getString());
	}

	if(f.equalsIgnoreCase(CUR_VAL))
	{
		setCurVal(v.getInt());
	}

	if(f.equalsIgnoreCase(CREATE_TIME))
	{
		setCreateTime(v.getString());
	}

	if(f.equalsIgnoreCase(LAST_UPDATE_TIME))
	{
		setLastUpdateTime(v.getString());
	}
	
}
public String toString()
{
	String msg = "TableSequence=\n";
	msg += "(\r\n";

	msg += "    ID(id)="+get("id")+"\r\n";

	msg += "    仓库编码(warehouse_code)="+get("warehouse_code")+"\r\n";

	msg += "    数据表名(datatable_name)="+get("datatable_name")+"\r\n";

	msg += "    当前值(cur_val)="+get("cur_val")+"\r\n";

	msg += "    创建时间(create_time)="+get("create_time")+"\r\n";

	msg += "    最后修改时间(last_update_time)="+get("last_update_time")+"\r\n";
		
	msg += ")\r\n";
	return msg;
}
public void copyBase(TableSequenceBase srcObj)
{

	setWarehouseCode(srcObj.getWarehouseCode());

	setDatatableName(srcObj.getDatatableName());

	setCurVal(srcObj.getCurVal());

	setCreateTime(srcObj.getCreateTime());

	setLastUpdateTime(srcObj.getLastUpdateTime());

}

public String toXml() throws Exception
{
	String xml = "";
	xml += "<TableSequence>";

	xml += "<Id>"+Value.view(getId())+"</Id>";

	xml += "<WarehouseCode>"+Value.view(getWarehouseCode())+"</WarehouseCode>";

	xml += "<DatatableName>"+Value.view(getDatatableName())+"</DatatableName>";

	xml += "<CurVal>"+Value.view(getCurVal())+"</CurVal>";

	xml += "<CreateTime>"+Value.view(getCreateTime())+"</CreateTime>";

	xml += "<LastUpdateTime>"+Value.view(getLastUpdateTime())+"</LastUpdateTime>";
	
	xml += "</TableSequence>";
	return xml;
}

}
